<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%String ctx = request.getContextPath();%>
<title>exam list</title>
</head>

<script>
	function joinExam(examId) {
		$.ajax(
				{
					type:"GET",
					url: '<%=ctx%>/u/exam?act=joinExam',
					dataType: "json",
					data: {
						"examid":examId,
					},
					success: function(data, status) {
						alert(data);
					},
				  	error: function(req, status, msg) {
					 	alert(msg);
				  	}
				}
			)
	}
</script>


<body>
	<div id="list" class="col-md-10 col-xs-12">
		<h3>考试列表</h3>
		<hr>
<table class="table table-hover">
	<thead> <tr>
		<th>序号</th>
		<th>考试</th>
		<th>状态</th>
		<th>选择考试</th>
		<th>客观题成绩</th>
	</tr></thead>
	
	<tbody id="exambody"> 
	<c:forEach items="${ExamList}" var="Exam" varStatus="s">
		<tr>
				<td>${s.index + 1}</td>
				<td>${Exam.name}</td>
				<c:choose>
					<c:when test="${Exam.enable eq 'True'}">
						<td style="width: 100px">正在进行</td>
					</c:when>
					<c:otherwise>
						<td style="width: 100px">已暂停</td>
					</c:otherwise>
				</c:choose>
				<td>
					<c:choose>
						<c:when test="${DoneList.get(s.index) eq true}">
							<button type="button" class="btn btn-danger">
								已交卷</button>
						</c:when>
						<c:otherwise>
							<button type="button" class="btn btn-success" onclick="joinExam(${Exam.id})">
								参加考试</button>
						</c:otherwise>
					</c:choose>


				</td>
			<td>
				<c:if test="${fn:length(Msg) gt 0}">
					<h4>${Msg}</h4>
				</c:if>
			</td>
		</tr>
	</c:forEach>
	</tbody>
</table>
	</div>
</body>
</html>